package pers.zc.activiti.thread;

/**
 * @Annotion: 多线程测试
 * @ClassName: TestThread
 * @Author: Lin Fuyuan
 * @Date: 2019/9/26  11:36
 * @Version: 1.0
 */
public class TestThread implements Runnable{

    private static int n = 1;
    public static boolean running = true;

    public static volatile String name = null;

    @Override
    public void run() {
       synchronized (this){
           name = Thread.currentThread().getName();
           while (true){
               System.out.println(n++);
               try {
                   Thread.sleep(500);
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
               if(!running){
                   try {
                       wait();
                   } catch (InterruptedException e) {
                       e.printStackTrace();
                   }
               }
           }
       }
    }
}
